﻿using System;
using StudentInfo.Security.Utilities;
using StudentInfo.Areas.AccountArea.Models;

namespace StudentInfo.Areas.AccountArea.Helpers
{
    public class AccountHelper
    {
        public static Account PopulateAccountFromRegisterViewModel(RegisterModel model)
        {
            byte[] salt;
            byte[] key;
            Cryptographer.Encrypt(model.Password, out salt, out key);

            return new Account
            {
                Id = Guid.NewGuid(),
                AccountName = model.AccountName,
                PasswordSalt = salt,
                PasswordKey = key,
                Email = model.Email,
                IsApproved = false
            };
        }
    }
}